Skip to main content

Symbolic link / Hard link on Windows

· One min read

AKA SymLink / Soft link

  • Symbolic link contains the text of target path
  • If target move / remove, the link is broken
  • Hard link is meta data of the file, that is inode on Linux
  • If target move / remove, the link is broken

Ref: mklink only available on cmd, not on PowerShell

cmd
mklink <link> <source>
PowerShell
New-Item -ItemType SymbolicLink -Path "<link>" -Target "<source>"
cmd
mklink /d <link> <source>
PowerShell
New-Item -ItemType SymbolicLink -Path "<link>" -Target "<source>"
cmd
mklink /h <link> <source>
PowerShell
New-Item -ItemType HardLink -Path "<link>" -Target "<source>"

Create directory junction

Hard link for directory

PowerShell
New-Item -ItemType Junction -Path "<link>" -Target "<source>"
cmd
mklink /j <link> <source>